from sqlalchemy import *
from migrate import *
from datetime import datetime

meta = MetaData(migrate_engine)
news = Table('news', meta,
  Column('id', Integer, autoincrement=True, primary_key=True),
  Column('date', DateTime,nullable=False,default=datetime.now),
  Column('title', Unicode(255)),
  Column('short_text', UnicodeText),
  Column('text', UnicodeText),
  Column('author_id', Integer, ForeignKey('tg_user.user_id')),
)
news_tags = Table('news_tags', meta,
     Column('news_id', Integer, ForeignKey('news.id')),
     Column('tag_id', Integer, ForeignKey('newsTag.id'))
)
newsTag= Table('newsTag', meta,
     Column('id', Integer, autoincrement=True, primary_key=True),
     Column('tag', Unicode(50), unique=True, nullable=False)
)
def upgrade():
    newsTag.create()
    news_tags.create()

def downgrade():
    news_tags.drop()
    newsTag.drop()
